package com.future.controller;

import com.future.common.annotation.ControllerMapping;
import com.future.common.annotation.NoNeedLogin;
import com.future.common.base.BaseController;
import com.future.common.exception.AppException;
import com.future.common.utils.IDUtil;
import com.future.dao.SysUserDao;
import com.future.model.SysUser;
import com.jfinal.aop.Inject;

import cn.hutool.crypto.SecureUtil;
/**
 * 用户信息controller
 * @author ThinkPad
 *
 */
@ControllerMapping("/user")
public class SysUserController extends BaseController {
	@Inject
	private SysUserDao sysUserDao;
	@NoNeedLogin
	public void register(String username, String password, String email){
		if(sysUserDao.findUserByUsername(username) !=null){
			throw new AppException("该用户名已经存在");
		}
		SysUser user =new SysUser();
		user.setUsername(username);
		user.setPassword(SecureUtil.md5(password));
		user.setEmail(email);
		user.setUserid(IDUtil.getId());
		user.save();
		renderSuccess();
	}
}
